package basic.com.liz.learn.design.singleton;

public class TestSingleTon
{
    String name = "sss";
    
    private TestSingleTon()
    {
    }
    
    private static volatile TestSingleTon instance = null;
    
    public static TestSingleTon getInstance()
    {
        if (instance == null)
        {
            synchronized (TestSingleTon.class)
            {
                if (instance == null)
                {
                    instance = new TestSingleTon();
                }
            }
        }
        return instance;
    }
    
    public String getName()
    {
        return name;
    }
    
    public void setName(String name)
    {
        this.name = name;
    }
    
    public void printInfo()
    {
        System.out.println("the name is " + name);
    }
    
}